package schema.controller;

import controller.*;
import java.sql.ResultSet;
import java.util.Vector;
import schema.model.SchemaTableColumn;

public class SchemaTableColumnMgr extends DbManager {
    public static final SchemaTableColumnMgr mgr = new SchemaTableColumnMgr();

    private SchemaTableColumnMgr() {
        super( "COLUMNS" );
        m_titles = new String[]{"NOMBRE", "TIPO", "DESCRIPCION" };
        m_nConnection = 2;
    }

    @Override
    protected SchemaTableColumn getBean() {
        return new SchemaTableColumn();
    }

    @Override
    public SchemaTableColumn getItem( String id ) {
        return (SchemaTableColumn) super.getItem( id );
    }

    @Override
    @SuppressWarnings("unchecked")
    protected void addObject( Vector v, ResultSet rs ) {
        v.add( new SchemaTableColumn( rs ) );
    }

    public synchronized Vector<SchemaTableColumn> getAllTables() {
        return executeQuery( "select * from Tables where TABLE_SCHEMA='AdultoMayor'" );
    }

    public synchronized Vector<SchemaTableColumn> getColumnsTable( String idTable ) {
        return executeQuery( "select * from COLUMNS where TABLE_NAME = '" + idTable + "'" );
    }
}